import { getOrderListData } from '@/services/api';

export default {
  namespace: 'OrderList',

  state: {
    orderList: {},
    updateDidFinish: false,
  },

  effects: {
    *getOrderList({ payload }, { call, put }) {
      // console.log('getOrderListData', payload);
      const response = yield call(getOrderListData, payload);
      console.log('getOrderList', response);
      yield put({
        type: 'setOrderList',
        payload: {
          orderList: response.data,
        },
      });
    },
  },

  reducers: {
    getOrderListData(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
    logPayload(state, action) {
      console.log(action.payload);
      return state;
    },
  },
};
